using System;
using System.Text;

namespace MathMLToCSharp.Entities
{
  /// <summary>
  /// Root element in MathML. Not to be confused with <c>System.Math</c>.
  /// </summary>
  public class Math : WithBuildableContents
  {
    public Math(string content) : base(new IBuildable []{}) { /* just in case */ }
    public Math(IBuildable content) : base(new[]{content}) {}
    public Math(IBuildable[] contents) : base(contents) {}
    public override void Visit(StringBuilder sb, BuildContext context)
    {
      base.Visit(sb, context);
      // variables
      int i = context.Vars.Count;
      if (i > 0)
      {
        var builder = new StringBuilder();
        foreach (var v in context.Vars)
        {
          if (context.Options.NumberPostfix)
            builder.Append(Semantics.postfixForDataType(context.Options.EqnDataType));
        }
        sb.Insert(0, builder.ToString());
      }
    }
  }
}